<?php require_once VIEWPATH . 'common/header.php'; ?>
<div class="page-container">
    <p class="f-20 text-success">欢迎使用蓝调管理平台！</p>
    <p>上次登录时间：<?=date("Y-m-d H:i:s",$_SESSION['adminUserInfo']['lastlogin'])?></p>
    <div class="row ">
        <div class="col-sm-1"></div>
        <div class="col-sm-2">
            <div class="widget style1">
                <div class="row">
                    <div class="col-xs-8 text-right">
                        <span class="c-green"> 今日订单 </span>
                        <h2 class="font-bold c-green"><?=$orders['today']?></h2>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-2">
            <div class="widget style1 navy-bg">
                <div class="row">
                    <div class="col-xs-8 text-right">
                        <span  class="c-green"> 今日采购金额 </span>
                        <h2 class="font-bold c-green">￥<?=$purchaseTotalPrice['today']?></h2>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-2">
            <div class="widget style1 lazur-bg">
                <div class="row">
                    <div class="col-xs-8 text-right">
                        <span  class="c-green"> 销售金额 </span>
                        <h2 class="font-bold c-green">￥<?=$selling_rice['today']?></h2>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-2">
            <div class="widget style1 yellow-bg">
                <div class="row">
                    <div class="col-xs-8 text-right">
                        <span  class="c-green"> 利润 </span>
                        <h2 class="font-bold c-green">￥<?=$profit['today']?></h2>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-2">
            <div class="widget style1 yellow-bg">
                <div class="row">
                    <div class="col-xs-12 text-right">
                        <span  class="c-333">待结算</span>
                        <h4 class="font-bold c-333">home&nbsp;&nbsp;：￥<?=$settle_accounts?></h4>
                        <h4 class="font-bold c-333">qingtai：￥<?=$settle_accounts_qingtai?></h4>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <table class="table table-border table-bordered table-bg">
        <thead>
        <tr>
            <th colspan="7" scope="col">信息统计</th>
        </tr>
        <tr class="text-c">
            <th>统计</th>
            <th>销售单数</th>
            <th>采购总金额</th>
            <th>销售总金额</th>
            <th>利润</th>
        </tr>
        </thead>
        <tbody>

        <tr class="text-c success">
            <td>本周</td>
            <td><?=$orders['week']?></td>
            <td><?=$purchaseTotalPrice['week']?></td>
            <td><?=$selling_rice['week']?></td>
            <td><?=$profit['week']?></td>
        </tr>
        <tr class="text-c warning">
            <td>本月</td>
            <td><?=$orders['month']?></td>
            <td><?=$purchaseTotalPrice['month']?></td>
            <td><?=$selling_rice['month']?></td>
            <td><?=$profit['month']?></td>
        </tr>
        <tr class="text-c danger">
            <td>总数</td>
            <td><?=$orders['total']?></td>
            <td><?=$purchaseTotalPrice['total']?></td>
            <td><?=$selling_rice['total']?></td>
            <td><?=$profit['total']?></td>
        </tr>
        </tbody>
    </table>
    <div class="row">&nbsp;</div>
    <p class="mt-5"><i class="Hui-iconfont mr-10">&#xe61e;</i>每月销售量&利润分析图</p>
    <hr />
    <p class="mt-20">
        <?php foreach($yearList as $row):?>
            <a href="/index/welcome?year=<?=$row?>"><button type="button" class="btn btn-outline <?php if($row == $switch_year):?>btn-primary<?php else:?>btn-info <?php endif;?> radius"><?=$row?></button></a>
        <?php endforeach;?>
    </p>
    <div id="main" class="float-e-margins" style="width: 100%;height:400px;">

    </div>
</div>
<?php require_once VIEWPATH . 'common/footer.php'; ?>
<script type="text/javascript" src="<?= STATICURL; ?>echar/echarts.min.js" ></script>

<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));
    myChart.title = '折柱混合';
    var cnt = new Array();
    cnt = <?= json_encode($hchar['cnt'],1)?>;
    var profit = new Array();
    profit = <?= json_encode($hchar['profit'])?>;
    var v_x = new Array();
    v_x = <?=json_encode($hchar['xAxis'])?>
    //console.log(profit);
    option = {
        tooltip: {
            trigger: 'axis',
        },
        toolbox: {
            feature: {
                dataView: {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            }
        },
        legend: {
            data:['利润','订单量']
        },
        xAxis: [
            {
                type: 'category',
                data: v_x,
                axisPointer: {
                    type: 'shadow'
                }
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: '利润',
                min: 0,
                //interval: 10000,
                axisLabel: {
                    formatter: '{value}￥'
                }
            },
            {
                type: 'value',
                name: '订单量',
                min: 0,
                //interval: 3,
                axisLabel: {
                    formatter: '{value}'
                }
            }
        ],
        series: [
            {
                name:'利润',
                type:'bar',
                data:profit,
                itemStyle:{
                    normal:{
                        color:'#57a9d4',
                    }
                }
            },
            {
                name:'订单量',
                type:'line',
                data:cnt,
                yAxisIndex: 1,
            },
        ]
    };


    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
</script>
